
<!-- 高亮关键词 函数式组件 -->
<script>
export default {
    name: "xszkHighKey",
    props:{
        keyWord: {
            type: Array,
            default: ()=>[]
        },
        text: {
            type: String,
            required: true //内容为空报错提示
        }

       
    },
    render (h) {
        const vnodes = []
        this.keyWord.forEach(key=>{
            const getText = this.text.split(key.value);
            getText.forEach(str => {
                vnodes.push(h('span', null, str))
                vnodes.push(h('span', { style: 'color: #F56060' }, key.value))
            })
            if (getText.length > 0) {
                vnodes.pop()
            }
        })
        return h('span', null, vnodes)
    }

};
</script>
